package scene.composants.elements;

import java.awt.BasicStroke;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Stroke;

import java.io.Serializable;

/**
 * Objet Graphique Ligne
 * Dessin d'une ligne suivant deux points
 * 
 * @author Delmas Gabriel
 */
public class Ligne implements Serializable
{
	private static final long serialVersionUID = -7916119565798788059L;
	
	private Point pSource, pDestination;
	private boolean estPointille;
	public Ligne(Point pdeb,Point pfin)
	{
		this.pSource=new Point(pdeb.x,pdeb.y);
		this.pDestination=new Point(pfin.x,pfin.y);
		estPointille=false;
	}
	
	public Point getPosition(){return pSource;}
	
	public void setPSource(Point pDeb){this.pSource=pDeb;}
	public Point getPSource(){return this.pSource;}
	
	public void setPDestination(Point pFin){this.pDestination=pFin;}
	public Point getPDestination(){return this.pDestination;}
	public void setEstPointille(boolean pointille)
	{
		this.estPointille=pointille;
	}
	public void dessiner(Graphics2D g2d)
	{
		if(this.estPointille)
		{
			Stroke strokeAncien= g2d.getStroke();
			g2d.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f,new float[]{.5f, .5f}, .0f));
			g2d.drawLine(this.pSource.x, this.pSource.y, this.pDestination.x, this.pDestination.y);
			g2d.setStroke(strokeAncien);
		}
		else
			g2d.drawLine(this.pSource.x, this.pSource.y, this.pDestination.x, this.pDestination.y);
	}

}
